# gflags.cmake
# 本文件包含着从外部导入 gflags 所需要的信息

SET(GFLAGS_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_rocksdb" CACHE PATH "Path to GFLAGS sources")
SET(GFLAGS_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "GFLAGS include directory." FORCE)
SET(GFLAGS_LIBRARIES "${LIB_INSTALL_DIR}/libzlib.a" CACHE FILEPATH "GFLAGS include directory." FORCE)

ExternalProject_Add(
        extern_gflags
        GIT_REPOSITORY https://github.com/gflags/gflags.git
        URL https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip
        CMAKE_ARGS
        -DCMAKE_INSTALL_PREFIX=${LIB_INSTALL_PREFIX}
        -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
        -DCMAKE_BUILD_TYPE=${LIB_BUILD_TYPE}
        BUILD_COMMAND make
)

ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET zlib PROPERTY IMPORTED_LOCATION ${ROCKSDB_LIBRARIES})
ADD_DEPENDENCIES(gflags extern_gflags)